package com.suntront.module_bluetooth.bluetoothlist

import com.mtjsoft.www.kotlinmvputils.base.BaseRecycleViewModel
import com.mtjsoft.www.kotlinmvputils.imp.AndCallBackListImp
import com.suntront.module_bluetooth.BlueToothTool
import com.suntront.module_bluetooth.model.BlueToothModel

/**
 * @author mtj
 * @Package com.mtjsoft.mvvmtest.bluetoothlist
 * @date 2020-05-21 13:28:46
 */

class BlueToothViewModel : BaseRecycleViewModel<BlueToothModel>() {
    /**
     * 分页获取列表数据
     */
    override fun getListDataInThread(pager: Int,callBackListImp: AndCallBackListImp<BlueToothModel>) {
        val list = BlueToothTool.instance.getBondedDevices()
        // 添加未配对标题
        val blueToothModel = BlueToothModel()
        blueToothModel.name = "未配对："
        blueToothModel.setItemType(BlueToothModel.TITLE_TYPE)
        list.add(blueToothModel)
        callBackListImp.onSuccess(list)
        // 开始扫描
        BlueToothTool.instance.startDiscovery()
    }
}